OTRcvReply
Reads a transaction reply sent by a connection-oriented responder.C INTERFACE
OSStatus OTRcvReply (EndpointRef ref, TReply* reply, OTFlags* replyFlags);C++ INTERFACE
OSStatus TEndpoint::RcvReply(TReply* reply, OTFlags* flags);PARAMETERS
ref
- The endpoint reference of the endpoint reading the reply.
reply
- A pointer to a
TReply
structure (page 3-67) that specifies the size and location of buffers into which the function, on return, stores data, option information, and the ID of the transaction. See the description of theTReply
structure for how to set this parameter when doing a no-copy receive.replyFlags
- A long bitmapped field specifying
T_MORE
orT_PARTIALDATA
. A value ofT_MORE
indicates that the buffer pointed to byreply->data.buf
is too small to contain the reply. A value ofT_PARTIALDATA
indicates that the data unit being read does not contain the complete reply and that the next data unit might belong to a different transaction.DESCRIPTION
You use theOTRcvReply
function to read the reply to a request that you sent using theOTSndRequest
function.If the endpoint is in asynchronous mode, the endpoint provider issues the
T_REPLY
event to let you know that incoming reply data is available. After you retrieve this event (using theOTLook
function or your notifier function,) you must call theOTRcvReply
function repeatedly to read the reply data until it returnskOTNoDataErr
. The endpoint provider does not generate additionalT_REPLY
events until you have read the complete reply.If a transaction has timed out awaiting reply data, the
OTRcvReply
function returns akETIMEDOUTErr
result; thesequence
field of thereply
parameter specifies which request has timed out.If you have issued multiple requests, it is not possible to know ahead of time how incoming replies match your requests. You must be prepared to receive a reply to any outstanding request. One way to manage this situation is to call the
OTRcvReply
function with thereply->udata.maxlen
field set to 0. The rest of the information returned by the function on this first call lets you know the sequence number of the reply as well as thereplyFlags
setting. Once you determine the matching request and the appropriate reply buffer, you can call theOTRcvReply
function a second time to read the actual reply data. On the second and subsequent reads, Open Transport sets thereply->opt.len
field to 0. It is guaranteed that once a reply has been partially read, subsequent calls toOTRcvReply
read from that same reply until all the data has been read.If the
T_MORE
bit is set in theflags
parameter, this means your buffer is not large enough to hold the entire reply. You must call theOTRcvRequest
function again to retrieve more request data. Open Transport ignores theaddr
andopt
fields of thereply
parameter for subsequent calls to the function. TheT_MORE
flag is not set for the last reply packet to let you know that this is the last packet.If the
T_PARTIALDATA
bit is set in theflags
parameter, this means that the data you are about to read with theOTRcvReply
function does not constitute the entire reply and that you must call the function again to read more of or the rest of the reply.If the
T_MORE
and theT_PARTIALDATA
bits are both set, this means that the data you are about to read constitutes only part of the reply and that your buffer is too small to contain even this chunk. In this case, you must call the function again until theT_MORE
flag is clear. TheT_PARTIALDATA
bit is set only on the first call to the function.If you are communicating with multiple responders and if the
OTRcvUReply
function returns with theT_PARTIALDATA
flag set, it is possible that your next call to the function might not read the rest of the reply because the next data unit coming in belongs to a different reply. One way to handle this situation is to use the next call to theOTRcvReply
function to determine the sequence number of the incoming reply (by settingreq->udata.maxlen
to 0) and then, having determined which reply data is coming in, read the data into the appropriate buffer.VALID STATES
T_IDLE
SEE ALSO
The request to which you are receiving a reply is defined by a previous call to theOTSndRequest
function (page 3-137).You use the
TReply
structure (page 3-67) to specify the size and location of buffers into which the function, on return, stores data, option information, and the ID of the transaction.You use the
OTLook
function (page 3-85) to poll for asynchronous events.